import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:laos_mall/common/style/app_style.dart';
import '../../../common/style/extension_util.dart';
class ListTitleWidget extends StatelessWidget {
  const ListTitleWidget({super.key,this.leading,this.spaceTitleMid = 3,this.trailing,this.title,this.subtitle,this.paddingOfLeft,this.spaceRight = 12,this.maxLeadingW = 80,this.showArrow = true, this.mainAxisAlignment, this.crossAxisAlignment,this.rowMainAxisAlignment,this.rowCrossAxisAlignment,this.isRow = false});
  final Widget? leading;
  final Widget? title;
  final Widget? subtitle;
  final Widget? trailing;
  final EdgeInsetsGeometry? paddingOfLeft;
  final double? spaceRight;
  final double maxLeadingW;
  final bool showArrow;
  final MainAxisAlignment? mainAxisAlignment;
  final CrossAxisAlignment? crossAxisAlignment;
  final MainAxisAlignment? rowMainAxisAlignment;
  final CrossAxisAlignment? rowCrossAxisAlignment;
  final double spaceTitleMid;
  final bool isRow;
  @override
  Widget build(BuildContext context) {

    Widget iconRight() => Icon(Icons.arrow_forward_ios,size: 13.w,color: AppColor.textColor2,);

    return Row(
      mainAxisAlignment: rowMainAxisAlignment ?? MainAxisAlignment.start,
      crossAxisAlignment: rowCrossAxisAlignment ?? CrossAxisAlignment.center,
      children: [
        Padding(padding: paddingOfLeft ?? EdgeInsets.symmetric(horizontal: 12),child:
        ConstrainedBox(constraints: BoxConstraints(maxWidth: maxLeadingW,maxHeight: maxLeadingW),child: leading,),),
        if (title != null && subtitle != null)
          if(isRow)
            Row(
              crossAxisAlignment: crossAxisAlignment ?? CrossAxisAlignment.center,
              mainAxisAlignment:  mainAxisAlignment ?? MainAxisAlignment.start,
              children: [
                title!,SizedBox(height: spaceTitleMid),subtitle!
              ],).addExpand()
            else
          Column(
            crossAxisAlignment: crossAxisAlignment ?? CrossAxisAlignment.start,
            mainAxisAlignment:  mainAxisAlignment ?? MainAxisAlignment.start,
            children: [
            title!,SizedBox(height: spaceTitleMid),subtitle!
        ],).addExpand()
        else if( title != null)
          title!.addExpand()
        else if( subtitle != null)
          subtitle!.addExpand()
        ,
        if(trailing != null)
          Stack(children: [
            trailing!,
            Align(alignment: Alignment.center,child: iconRight().addVisibility(showArrow),)
          ],)
        else
          iconRight().addVisibility(showArrow)
        ,
        SizedBox(width: spaceRight,)
      ],
    );
  }
}
